package com.kk.base.entity.home;

import com.kk.base.annotion.ValidateEntity;
import com.kk.base.entity.BaseEntity;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * @info : 前台用户地址实体类
 */
@Entity
@Table(name="home_user_address")
@EntityListeners(AuditingEntityListener.class)
@ToString
@Data
public class HomeUserAddress extends BaseEntity {

    public static final Integer DEFAULT = 0;
    public static final Integer NOTDEFAULT = 1;


    @ManyToOne
    @JoinColumn(name="home_user_id")
    private HomeUser homeUser;  //所属前台用户

    @Column(name="mobile",nullable=false)
    private String mobile;//手机号

    @Column(name="phone",nullable=false)
    private String phone;//座机号

    @ValidateEntity(required=true,errorRequiredMsg="姓名不能为空!")
    @Column(name="name",nullable=false)
    private String name;//姓名

    @ValidateEntity(required=true,errorRequiredMsg="地址不能为空!")
    @Column(name="address",nullable=false)
    private String address; //地址（省市区）

    @ValidateEntity(required=true,errorRequiredMsg="详细地址不能为空!")
    @Column(name="detailed_address",nullable=false)
    private String detailedAddress; //详细地址

    @Column(name="is_default",length=1)
    private Integer isDefault = NOTDEFAULT; //是否是默认地址  0是默认的，1是不默认的

    @ValidateEntity(required=true,errorRequiredMsg="寄件人地址或收件人地址请选择一个!")
    @Column(name="home_user_type")
    private HomeUserTypeEnum homeUserType; //寄件人地址还是收件人地址


}
